package com.yiwei.ydd.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yiwei.ydd.R;
import com.yiwei.ydd.api.model.CashBackListsModel;
import com.yiwei.ydd.util.DateTime;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by xsooy-pc on 2017/10/23.
 */

public class RetrunCashChildAdapter extends ItemAdapter<CashBackListsModel.DatasBean.ItemsBean, RetrunCashChildAdapter.DefaultHolder> {



    public RetrunCashChildAdapter(Context context) {
        super(context);
    }

    @Override
    public DefaultHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new DefaultHolder(inflate(R.layout.item_child_packet_sec, parent));
    }

    @Override
    public void onBindViewHolder(DefaultHolder holder, int position) {
        CashBackListsModel.DatasBean.ItemsBean item = getItem(position);
        holder.txtTime.setText(DateTime.toDate(Long.valueOf(item.get_sdate) * 1000));
        //分期状态（-1：失败，1：完成，2：待领取）
        String status = "";
        switch (item.status) {
            case "-1":
                status = "失败";
                holder.txtStatus.setTextColor(0xff999999);
                break;
            case "1":
                status = "已到账";
                holder.txtStatus.setTextColor(0xffFB5E01);
                break;
            case "2":
                status = "待返现";
                holder.txtStatus.setTextColor(0xff999999);
                break;
        }
        holder.txtStatus.setText(status);
        holder.txtMoney.setText(item.money + "(" + item.period + "/" + item.periods + ")");

    }

    class DefaultHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.txt_money)
        TextView txtMoney;
        @BindView(R.id.txt_time)
        TextView txtTime;
        @BindView(R.id.txt_status)
        TextView txtStatus;
        public DefaultHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
